package weekMatch.one_340;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

public class LeeCode_01 {
    public static void main(String[] args) {
        System.out.println(diagonalPrime(new int[][]{{1}}));
    }
    private static int diagonalPrime(int[][] nums) {
        List<Integer> list = new ArrayList<>();
        int n = nums[0].length;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (iszhi(nums[i][i])){
                ans = Math.max(ans, nums[i][i]);
            }
        }
        for (int i = n - 1, j = 0; i >= 0; i--, j++) {
            if (iszhi(nums[i][j])){
                ans = Math.max(ans, nums[i][j]);
            }
        }
        return ans;
    }
    private static boolean iszhi(int n){
        if (n == 1)
            return false;
        double m = Math.pow(n, 0.5);
        for (int i = 2; i <= m; i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }
}
